Skip to content

fix(trezor-client): handle button request during eth sign data streaming#6873

Merged
romanz merged 1 commit intomainfrom
fix/trezor-client-eth-sign-handle-button-requests
May 8, 2026
Merged

fix(trezor-client): handle button request during eth sign data streaming#6873
romanz merged 1 commit intomainfrom
fix/trezor-client-eth-sign-handle-button-requests

Conversation

@martykan
Copy link
Copy Markdown
Member

@martykan martykan commented May 5, 2026

A customer reported an issue when signing using Trezor T with Foundry, which is a CLI tool for EVM development that integrates with Trezor through trezor-client.
These contracts deployment TXs are often quite large (several kilobytes) and the customer found that the process froze while loading.
The root cause was that the TX data streaming was interrupted by a ButtonRequest, which was not handled by trezor-client logic.
This PR adds handle_interaction when streaming the TX data.

Can be tested using:

cargo run --example eth_sign_tx_large

After the fix is merged we should consider making a trezor-client release

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09546a1f-3dbf-46ac-b090-e5a60656d414

📥 Commits

Reviewing files that changed from the base of the PR and between d1c3efd and 07e9e85.

📒 Files selected for processing (4)
  • rust/trezor-client/examples/eth_sign_tx_large.rs
  • rust/trezor-client/src/client/ethereum.rs
  • rust/trezor-client/src/client/mod.rs
  • rust/trezor-client/src/lib.rs
✅ Files skipped from review due to trivial changes (1)
  • rust/trezor-client/examples/eth_sign_tx_large.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • rust/trezor-client/src/client/ethereum.rs
  • rust/trezor-client/src/client/mod.rs
  • rust/trezor-client/src/lib.rs

Walkthrough

Added an example binary that signs a 10KB Ethereum payload and prints the signature. Added Trezor::send_message to send a ProtoMessage without waiting for a response. Changed ethereum_sign_tx and ethereum_sign_eip1559_tx to route each per-chunk ack through handle_interaction(self.call(... )?)? instead of unwrapping with .ok()?. Expanded #[cfg(test)] tests: added with_auto_approve helper, updated the ECDH test to use it, and added test_ethereum_sign_tx_large that signs the 10KB payload against the emulator.

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant Client
  participant Handler
  participant Device
  App->>Client: ethereum_sign_tx(path payload)
  Client->>Device: send SignTx request
  Device-->>Client: EthereumTxRequest (data_length > 0)
  loop for each chunk
    Client->>Client: prepare TxAck
    Client->>Handler: handle_interaction(self.call(ack))
    Handler->>Device: transport I/O
    Device-->>Handler: chunk response
    Handler-->>Client: EthereumTxRequest
  end
  Device-->>Client: final signature
  Client-->>App: return signature
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description explains the issue, root cause, solution, and testing instructions but lacks standard repository process details like assignment and project setup, which appear to be required by the template. Complete the PR description by adding the standard sections specified in the template: Assign yourself, add to 'Firmware' project with priority/team/sprint, and set appropriate development status.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: handling button requests during Ethereum transaction data streaming. It directly reflects the primary change in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/trezor-client-eth-sign-handle-button-requests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@trezor-bot trezor-bot Bot added this to Firmware May 5, 2026
@github-project-automation github-project-automation Bot moved this to 🔎 Needs review in Firmware May 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

en main(all)

model device_test click_test persistence_test
T2T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all) test(all) main(all)

Latest CI run: 25556820684

@martykan martykan added the rust Pull requests that update Rust code label May 5, 2026
@martykan martykan marked this pull request as ready for review May 5, 2026 09:41
@martykan martykan requested a review from obrusvit as a code owner May 5, 2026 09:41
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rust/trezor-client/src/client/ethereum.rs`:
- Around line 95-97: The EIP-1559 signing loop in ethereum_sign_eip1559_tx still
uses direct .ok()? which skips mid-stream ButtonRequest handling; update that
loop to mirror the earlier interaction handling by invoking handle_interaction
with the call to self.call(ack, Box::new(|_, m: protos::EthereumTxRequest|
Ok(m)))? and assigning its result to resp (or similar), instead of using .ok()?,
so ButtonRequest/interaction messages are properly processed; ensure you use the
same pattern and error propagation as the existing non-EIP-1559 path
(handle_interaction(...)?).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 721445fa-2444-4985-b2bd-02b63574a219

📥 Commits

Reviewing files that changed from the base of the PR and between b94395e and 3f30807.

📒 Files selected for processing (2)
  • rust/trezor-client/examples/eth_sign_tx_large.rs
  • rust/trezor-client/src/client/ethereum.rs

Comment thread rust/trezor-client/src/client/ethereum.rs
@martykan martykan force-pushed the fix/trezor-client-eth-sign-handle-button-requests branch from 3f30807 to d9ba6b5 Compare May 5, 2026 09:48
Copy link
Copy Markdown
Contributor

@romanz romanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Comment thread rust/trezor-client/examples/eth_sign_tx_large.rs
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rust/trezor-client/src/lib.rs`:
- Around line 271-274: Replace the use of
tracing_subscriber::fmt().with_max_level(tracing::Level::TRACE).init() with
try_init() in the test functions so multiple tests can install the global
subscriber without panicking; update both test_ethereum_sign_tx_large (currently
calling .init()) and test_ecdh_shared_secret (the other test that calls .init())
to call .try_init() and handle the Result (e.g., ignore or unwrap appropriately)
so the tests don't panic when run together.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ad14e78e-87d5-466a-928c-026454caa0ba

📥 Commits

Reviewing files that changed from the base of the PR and between d9ba6b5 and 173e644.

📒 Files selected for processing (2)
  • rust/trezor-client/src/client/mod.rs
  • rust/trezor-client/src/lib.rs

Comment thread rust/trezor-client/src/lib.rs Outdated
@romanz romanz requested a review from mmilata May 6, 2026 07:17
Copy link
Copy Markdown
Member

@mmilata mmilata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer not to use threads unless justified, but for tests I suppose it's OK. Thanks!

@romanz
Copy link
Copy Markdown
Contributor

romanz commented May 8, 2026

Squashing before merge.

@romanz romanz force-pushed the fix/trezor-client-eth-sign-handle-button-requests branch from d1c3efd to 07e9e85 Compare May 8, 2026 12:56
@romanz romanz added the no-QA On PR-merge, automatically transition status in the "Firmware" project to "Done (no QA)" state. label May 8, 2026
@romanz romanz merged commit 0406f23 into main May 8, 2026
112 of 160 checks passed
@romanz romanz deleted the fix/trezor-client-eth-sign-handle-button-requests branch May 8, 2026 13:50
@trezor-bot trezor-bot Bot moved this from 🔎 Needs review to ✅ Done (no QA) in Firmware May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-QA On PR-merge, automatically transition status in the "Firmware" project to "Done (no QA)" state. rust Pull requests that update Rust code

Projects

Status: ✅ Done (no QA)

Development

Successfully merging this pull request may close these issues.

3 participants